package com.it.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.it.domain.Order;
import com.it.domain.dto.FenPaiDto;
import com.it.domain.dto.OrderDto;
import com.it.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author: zgc
 * @version: 1.0
 * @description:
 * @date: 2024/9/2 16:15
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("/search")
    public IPage<Order> search(@RequestBody OrderDto dto){
        return orderService.search(dto.getPageNo(),dto.getPageSize());
    }

    @PostMapping("/save")
    public int save(@RequestBody Order order){
        return orderService.saveOrder(order);
    }

    @PostMapping("/update")
    public boolean update(@RequestBody Order order){
        return orderService.updateById(order);
    }

    @PostMapping("/delete")
    public int delete(@RequestBody Order order){
        return orderService.delete(order.getId());
    }

    @PostMapping("/fenpai")
    public String fenpai(@RequestBody FenPaiDto dto) throws ParseException {
        return orderService.fenpai(dto);
    }


    @PostMapping("/five")
    public Map<String,List<HashMap>> five(){
        return orderService.five();
    }


}
